home *** CD-ROM | disk | FTP | other *** search
/ PC Graphics Unleashed / PC Graphics Unleashed.iso / ch17 / pi / texture / texture.pi < prev   
Encoding:
Text File  |  1994-08-05  |  1.6 KB  |  73 lines

  1. // Scene File: TEXTURE.PI
  2. // Author: Rob McGregor
  3.  
  4. // A sphere changes from dull red to reflective blue and back again
  5.  
  6. include "..\..\..\colors.inc"
  7.  
  8. // Set up the camera
  9. viewpoint {
  10.   from       <3, 0, -10>
  11.   at         <0, 0, 0>
  12.   up         <0, 1, 0>
  13.   angle      45
  14.   resolution 320, 200
  15.   aspect     1.6
  16. }
  17.  
  18. background grey
  19. haze 0.98, 20, grey
  20.  
  21. // Lights
  22. light <-5, 5, -20>
  23. light <5, 5, -20>
  24.  
  25. // Define the range of animation
  26. start_frame  0
  27. end_frame    199
  28. outfile      "tex" 
  29.  
  30. // Interpolate the proper texture shift
  31. if (frame <= end_frame / 2) {
  32.   define ch (frame - start_frame) / ((end_frame / 2) - start_frame)
  33.   define r  (1 - ch)^2 * 1 + (ch^2) * 0 + 2 * ch * (1 - ch) * 0.5
  34.   define b  (1 - ch)^2 * 0 + (ch^2) * 1 + 2 * ch * (1 - ch) * 0.5
  35. }
  36. else {
  37.   define ch (frame - (end_frame / 2)) / (end_frame - (end_frame / 2))
  38.   define r  (1 - ch)^2 * 0 + (ch^2) * 1 + 2 * ch * (1 - ch) * 0.5
  39.   define b  (1 - ch)^2 * 1 + (ch^2) * 0 + 2 * ch * (1 - ch) * 0.5
  40. }
  41.  
  42. define g   0 
  43. define val b / 1.5
  44.  
  45. // Create the animated texture 
  46. define sphere_tex
  47. texture {
  48.   surface { 
  49.     color      <r, g, b>
  50.     ambient    0.25
  51.     diffuse    0.7
  52.     specular white, val
  53.     microfacet Phong 5
  54.     reflection white, val / 1.75
  55.   }
  56. }
  57.  
  58. // Define the sphere
  59. object { sphere <0, 0, 0>, 2 sphere_tex }
  60.  
  61. // Give the sphere something to reflect
  62. object {
  63.   disc <0, 0, 0>, <0, 1, 0>, 10000
  64.   texture { 
  65.     hexagon reflective_brown, reflective_tan, reflective_white 
  66.     scale <1.5, 1, 1.5>
  67.   }
  68.   rotate <0, 40, 0>
  69.   translate <0, -2, 0>
  70. }
  71.  
  72.  
  73.